/*
* @(#)ListDmsArchiveDetailForm.java
*
* Copyright (c) 2003 DCIVision Ltd
* All rights reserved.
*
* This software is the confidential and proprietary information of DCIVision
* Ltd ("Confidential Information").  You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license
* agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.dms.web;

import java.util.Calendar;

import com.dcivision.framework.SystemParameterConstant;
import com.dcivision.framework.SystemParameterFactory;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.Utility;
import com.dcivision.framework.web.AbstractSearchForm;

/**
  ListDmsArchiveDetailForm.java

  The ActionForm for ListDmsArchiveDetailForm

    @author          Angus Shiu
    @company         DCIVision Limited
    @creation 18   01/09/2003
    @version         $Revision: 1.5 $
    */
public class ListDmsArchiveDetailForm extends AbstractSearchForm {

  public static final String REVISION = "$Revision: 1.5 $";


  /** Holds value of property archivedFrom.  */
  private String archivedFrom;

  /** Holds value of property archivedTo.  */
  private String archivedTo;

  /** Holds value of property periodType.   */
  private String periodType="";

  /** Holds value of property archiveID.   */
  private String archiveID;
  
  /** Holds value of property archiveName.   */
  private String archiveName;
  
  /** Holds value of property versionLabel.   */
  private String versionLabel;
  
  /** Holds value of property documentName.   */
  private String documentName;
  
  /** Holds value of property withinCurrentArchive.   */
  private String withinCurrentArchive;
  
  private String[] selectedDoc;
  
  private String archiveSegmentID;
  
  public ListDmsArchiveDetailForm() {
    super();
    this.setSortAttribute("CREATE_DATE");
    this.setSortOrder("DESC");
  }

  /** Getter for property updateDateFrom.
   * @return Value of property updateDateFrom.
   */
  public String getArchivedFrom() {
    Calendar cal = Calendar.getInstance();
    if(Utility.isEmpty(periodType)){
      return archivedFrom;
    }else if("week".equals(periodType)){
      cal.add(Calendar.DATE,1-cal.get(Calendar.DAY_OF_WEEK));
    }else if("month".equals(periodType)){
      cal.set(Calendar.DATE,1);
    }else if("full".equals(periodType)){
      return null;
    }
    cal.set(Calendar.AM_PM, Calendar.AM);
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return TextUtility.formatDate(cal.getTime(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT));
  }

  /** Setter for property updateDateFrom.
   * @param updateDateFrom New value of property updateDateFrom.
   */
  public void setArchivedFrom(String archivedFrom) {
    this.archivedFrom = archivedFrom;
  }

  /** Getter for property updateDateTo.
   * @return Value of property updateDateTo.
   */
  public String getArchivedTo() {
    Calendar cal = Calendar.getInstance();
    if(Utility.isEmpty(periodType)){
      return archivedTo;
    }else if("week".equals(periodType)){
      cal.add(Calendar.DATE,7-cal.get(Calendar.DAY_OF_WEEK));
    }else if("month".equals(periodType)){
      cal.add(Calendar.MONTH,1);
      cal.set(Calendar.DATE,0);
    }else if("full".equals(periodType)){
      return null;
    }
    cal.set(Calendar.AM_PM, Calendar.PM);
    cal.set(Calendar.HOUR, 11);
    cal.set(Calendar.MINUTE, 59);
    cal.set(Calendar.SECOND, 59);
    cal.set(Calendar.MILLISECOND, 59);
    return TextUtility.formatDate(cal.getTime(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT));
  }

  /** Setter for property updateDateTo.
   * @param updateDateTo New value of property updateDateTo.
   */
  public void setArchivedTo(String archivedTo) {
    this.archivedTo = archivedTo;
  }

  /** Getter for property periodType.
   * @return Value of property periodType.
   */
  public String getPeriodType() {
    return this.periodType;
  }
  public void setPeriodType(String periodType){
    this.periodType = periodType;
  }
  
  public String getArchiveID() {
    return this.archiveID;
  }
  
  public void setArchiveID(String archiveID) {
    this.archiveID = archiveID;
  }

  public String getArchiveName() {
    return (this.archiveName);
  }
  
  public void setArchiveName(String archiveName) {
    this.archiveName = archiveName;
  }
  
  public String getVersionLabel() {
    return (this.versionLabel);
  }
  
  public void setVersionLabel(String versionLabel) {
    this.versionLabel = versionLabel;
  }
  
  public String getDocumentName() {
    return (this.documentName);
  }
  
  public void setDocumentName(String documentName) {
    this.documentName = documentName;
  }
  
  public String[] getSelectedDoc() {
    return (this.selectedDoc);
  }
  
  public void setSelectedDoc(String[] selectedDoc) {
    this.selectedDoc = selectedDoc;
  }
  
  public String getWithinCurrentArchive() {
    return (this.withinCurrentArchive);
  }
  
  public void setWithinCurrentArchive(String withinCurrentArchive) {
    this.withinCurrentArchive = withinCurrentArchive;
  }
  
  public String getArchiveSegmentID() {
    return (this.archiveSegmentID);
  }
  
  public void setArchiveSegmentID(String archiveSegmentID) {
    this.archiveSegmentID = archiveSegmentID;
  }
}
